package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.sql.SQLOutput;

public class RflectDemo6 {
    public static void main(String[] args) throws NoSuchMethodException, ClassNotFoundException {
        Class cls=Class.forName("reflect.Person");
        Method method=cls.getMethod("say",String.class,int.class);
        String name=method.getName();
        System.out.println("方法名："+name);

        Class returnType=method.getReturnType();
        System.out.println("返回值类型："+returnType);

        Class[] parameterType=method.getParameterTypes();
        for(Class c:parameterType){
            System.out.println("参数类型："+c);
        }

        int count=method.getParameterCount();
        System.out.println("参数个数："+count);

        int modifiers=method.getModifiers();
        switch(modifiers){
            case Modifier.PUBLIC:
                System.out.println("访问修饰符：public");
                break;
                case Modifier.PRIVATE:
                System.out.println("访问修饰符：private");
                break;
                case Modifier.PROTECTED:
                System.out.println("访问修饰符：protected");
                break;
                default:
                System.out.println("访问修饰符：default");
                break;
        }
    }
}
